<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增报价方案年利率配置</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<form id="formSet1">
		<div class="fieldset1 tabel_col clearFix">
			<div class="fieldBox col_100_auto">
                <div class="label">开始期数</div>
                <div class="field">
                	<input type="text" id="stNum" name="stNum" class="ui-textbox" validate ="{required:true,number:true}"/>
                	<span class="requiredSymbol">*</span>
                </div>
            </div>
			<div class="fieldBox col_100_auto">
                <div class="label">结束期数</div>
                <div class="field">
                	<input type="text" id="endNum" name="endNum" class="ui-textbox" validate ="{required:true,number:true}"/>
                	<span class="requiredSymbol">*</span>
                </div>
            </div>
			<div class="fieldBox col_100_auto">
				<div class="label">租赁期数单位</div>
				<div class="field">
					<!-- <input type="text" id="stNum" name="stNum" class="ui-textbox" ligerui="width: 55" validate ="{required:true,number:true}"/>
					<span>&nbsp;-&nbsp;</span>
					<input type="text" id="endNum" name="endNum" class="ui-textbox" ligerui="width: 55" value="" validate ="{required:true,number:true}"/> -->
                   	<select name="lsPdUntCd" id="lsPdUntCd" data-value="">
						<c:forEach items="${lsPdUntCdList }" var="kv" begin="0" step="1" varStatus="status">
							<c:if test="${status.index == 0}">
						    	<option value="${kv.key }" checked >${kv.value }</option>
							</c:if>
						    <c:if test="${status.index != 0}">
						    	<option value="${kv.key }">${kv.value }</option>
						 	</c:if>
						</c:forEach>
					</select>
					<span class="requiredSymbol">*</span>
				</div>
			</div>
			<div class="fieldBox col_100_auto">
				<div class="label">年利率(%)</div>
					<div class="field">
						<input type="text" id="annIntRatePct" name="annIntRatePct" class="ui-textbox" data-tofix="${annIntScale }" validate ="{required:true,number:true}"/>
						<span class="requiredSymbol">*</span>
					</div>
			</div>
			<div class="fieldBox col_100_auto">
				<div class="label">新能源年利率(%)</div>
					<div class="field">
						<input type="text" id="annIntRatePct2" name="annIntRatePct2" class="ui-textbox" data-tofix="${annIntScale }"/>
					</div>
			</div>
			<div class="fieldBox col_100_auto">
				<div class="label">是否允许变更</div>
					<div class="field">
						<select name="isAllowChg" id="isAllowChg" data-value="">
							<c:forEach items="${yesOrNoCdList }" var="kv" begin="0" step="1" varStatus="status">
								<c:if test="${status.index == 0}">
							    	<option value="${kv.key }" checked >${kv.value }</option>
								</c:if>
							    <c:if test="${status.index != 0}">
							    	<option value="${kv.key }">${kv.value }</option>
							 	</c:if>
							</c:forEach>
						</select>
	                    <input name="aiId" id="aiId" type="hidden" value="${id }">
					</div>
			</div>
		</div>
</form>
</div>


<script type="text/javascript">
var _prpsCfgId = '${prpsCfgId}';
$(function(){
	initData();
	var formSet1 = $('#formSet1').ligerForm({
	        validate : true
	});
	initData();
	SET_popupIframeHeight();
});
//定义父级调用事件
frameElement.dialog.onOk = function () {
     save();
}
frameElement.dialog.onCancel = function () {
     frameElement.dialog.close();
}
function save(){
	var form = liger.get("formSet1");
    if (!form.valid()) {
    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false; //验证不通过，不执行以下代码
    }
    
    var data = form.getData();
    var id = $("#aiId").val();
    data["prpsCfgId"] = _prpsCfgId;
    var url = '<%=path%>/project/prjQuatPrpsCfgAi/add.do';
    if(id != ""){
    	url = '<%=path%>/project/prjQuatPrpsCfgAi/modify.do';
    	data["id"]= id;
    }
    var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: url,
		beforeSend: function(){
	          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 //回到刷新列表
				 //var callback=frameElement.W2W.callback;
	             parent.callback();//刷新账号列表
	             frameElement.dialog.close();//关闭弹出框
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}
	function initData(){
		var id = $("#aiId").val();
    	if(!id){
    		return;
    	}
    	var _url = '<%=path%>/project/prjQuatPrpsCfgAi/getById.do';
    	$.ajax({
    		type: 'get',
    		dataType:'json',
    		data:{id:id},
    		url: _url,
    		success:function(msg){
    			 if(msg.success == 1){
    				 setData(msg.data);//设置数据
    			 }else{
    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
   	}
		
	//设置页面数据
    function setData(data){
    	var form = liger.get("formSet1");
    	form.setData({
    		lsPdUntCd:data.lsPdUntCd,
    		isAllowChg:data.isAllowChg.toString()
    	});
    	$("#stNum").val(data.stNum);
    	$("#endNum").val(data.endNum);
    	$("#annIntRatePct").val(data.annIntRatePct);
    	$("#annIntRatePct2").val(data.annIntRatePct2);
    	
	};

</script>



</body>
</html>
